package org.dtrevien.metamodel.java;

public enum Visibility {

	/**
	 * -, #, +, ~ in UML
	 */
	PRIVATE, PROTECTED, PUBLIC, PACKAGE;
	
	/**
	 * Get a Visibility for the given string
	 * @param v
	 * @return
	 */
	public static Visibility string2Visibility(String v) {
		if (v.equals("+")) {
			return PUBLIC;
		}
		else if (v.equals("-")) {
			return PRIVATE;
		}
		else if (v.equals("#")) {
			return PROTECTED;
		}
		else {
			return PACKAGE;
		} 
	}
	
	/**
	 * Get a String for the given Visibility
	 * @param v
	 * @return
	 */
	public static String visibility2string(Visibility v) {
		switch (v) {
		case PUBLIC: return "+";
		case PACKAGE: return "~";
		case PRIVATE: return "-";
		case PROTECTED: return "#";
		}
		return null;
	}
}
